package cn.moningxi.service.impl;


import cn.moningxi.bean.OShopCart;
import cn.moningxi.mapper.OShopCartMapper;
import cn.moningxi.service.OShopCartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class OShopCartServiceImpl implements OShopCartService {

    @Autowired
    private OShopCartMapper oShopCartMapper;

    @Override
    public Integer removeShopCart(Integer shopCartId) {
        return oShopCartMapper.removeShopCart(shopCartId);
    }

    @Override
    public List<OShopCart> queryShopCartList(String customerId) {
        return oShopCartMapper.queryShopCartList(customerId);
    }

    @Override
    public OShopCart queryShopCartByGoodsId(String goodsId) {

        return oShopCartMapper.queryShopCartByGoodsId(goodsId);
    }

    @Override
    public Integer insertShopCart(OShopCart oShopCart) {
        oShopCart.setAddTime(LocalDateTime.now());
        return oShopCartMapper.insertShopCart(oShopCart);
    }

    @Override
    public Integer updateShopCartAmount(OShopCart oShopCart) {
        oShopCart.setModifiedTime(LocalDateTime.now());
        return oShopCartMapper.updateShopCartAmount(oShopCart);
    }

    /**
     * 根据商品id和顾客id查询购物车
     *
     * @param goodsId
     * @param customerId
     * @return
     */
    @Override
    public OShopCart queryShopCartByGoodsIdAndCid(String goodsId, String customerId) {
        return oShopCartMapper.queryShopCartByGoodsIdAndCid(goodsId, customerId);
    }

    @Override
    public OShopCart queryShopCartById(Long shopCartId) {
        return oShopCartMapper.queryShopCartById(shopCartId);
    }

    @Override
    public Integer updateShopCartAmount1(Integer shopCartId, Integer amount) {
        return oShopCartMapper.updateShopCartAmount1(shopCartId, amount);
    }

}
